#include <iostream>
using namespace std;
class Card{
private:
    char color;
    int num;
public:
    void setinfo(int index){
	int col=index/13;
	if(index%13==0){
	    col--;
	}
	switch(col){
	case 0:
	    color='S';
	    break;
	case 1:
	    color='H';
	    break;
	case 2:
	    color='C';
	    break;
	case 3:
	    color='D';
	    break;
	case 4:
	    color='J';
	    break;
	}
	num=index-col*13;
    }
    void print1(){
	cout<<color<<num<<" ";
    }
    void print2(){
	cout<<color<<num<<endl;
    }
};
int main(){
    Card card[55];
    Card copy_card[55];
    int shuffseq[55];
    for(int i=1;i<=54;i++){
	card[i].setinfo(i);
	copy_card[i]=card[i];
    }
    int repeat;
    cin>>repeat;
    for(int i=1;i<=54;i++){
	cin>>shuffseq[i];
    }
    for(int i=0;i<repeat;i++){
	for(int j=1;j<=54;j++){
	    copy_card[shuffseq[j]]=card[j];
	}
	for(int j=1;j<=54;j++){
	    card[j]=copy_card[j];
	}
    }
    for(int i=1;i<=53;i++){
	card[i].print1();
    }
    card[54].print2();
}
